Skip to content

fix(fold): report a timed-out pose dispatch as possibly applied, and end lit-panel reads at their deadline - #5031

Merged
thymikee merged 6 commits into
callstack:mainfrom
imranbarbhuiya:fix/fold-followups
Nov 23, 2026
Merged

thymikee merged 6 commits into
callstack:mainfrom
imranbarbhuiya:fix/fold-followups

Conversation

@imranbarbhuiya

@imranbarbhuiya imranbarbhuiya commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #5012 and #5019.

  • A timed-out fold helper set reported fold-hid-dispatch-failed ("Unable to send"), although the hinge can still move after the deadline. fold already carried dispatched: unknown; it now also gets fold-hid-dispatch-timed-out, a "may have applied" message, and a hint saying what a retry sends (the named pose again, or the keyframes from the first). A helper exit failure is unchanged.
  • On Android, a late console answer to posture was a plain adb timeout. It now reports fold-posture-dispatch-timed-out the same way.
  • The lit-panel poll gave every read at least 500 ms, so a late read could run past the 5 s deadline. Each read's timeout now ends at the deadline, as ADR 0025 says. Trade-off: the last read starts by 4.5 s, so a panel switch in the final ~0.5 s is missed and screen is omitted. The fold budget is unchanged.
  • Comments note what the ledger test bounds and the 1 s kill grace on a timed-out read.

Before / after

From the Apple and Android fold unit tests:

$ fold open   (the helper's set mode times out)
base: Unable to send the simulator hinge pose
      reason fold-hid-dispatch-failed
head: Timed out sending the simulator hinge pose; the pose may have applied
      reason fold-hid-dispatch-timed-out

$ fold open   (300 ms panel reads, the lit panel never switches)
base: last read's timeout ends 5300 ms after the poll starts
head: last read's timeout ends 5000 ms after the poll starts

$ fold open   (Android, the console answers the posture late)
base: adb timed out after 10000ms
head: Timed out setting the emulator posture for open; the posture may have applied
      reason fold-posture-dispatch-timed-out

Validation

  • check:affected --run --head 97e2bc2b6, exactCommit: true: format, lint, typecheck, layering, fallow, build, and vitest-related pass.
  • At 97e2bc2b6: foldable unit tests 162/162, ios-fold.test.ts 7/7. The new cases fail on base.
  • iPhone Duo simulator (iOS 27.2) at 97e2bc2b6, each fold followed by screenshot; the scoped run went through simctl --set:
default set: closed LCD 466x678 | half-open 123.4° LCD-1 669x951 | open LCD-1 669x951
scoped set:  closed LCD 466x678 | half-open 123.4° LCD-1 669x951 | open LCD-1 669x951

Every screenshot matched the reported panel, and a Settings tap after fold open worked in both sets.

The fold helper's set mode can finish sending the pose after its exec deadline,
so a timeout no longer reads as an unsent pose. It now refuses with
fold-hid-dispatch-timed-out and dispatched: unknown, and the hint says to check
the pose and what a retry sends. A helper that exits with a failure keeps
fold-hid-dispatch-failed.
The last lit-panel read after a named pose got at least 500 ms, so a read that
started at the deadline could run past it. The poll now starts its last read at
the latest 500 ms before the deadline, and each read's timeout is the time left
until that deadline, so every read's timeout ends at the deadline that ADR 0025
and the config describe. A read that starts late, after the deadline, gets 1 ms,
because a zero exec timeout means no timeout.
@thymikee

Copy link
Copy Markdown
Member

Thanks for the careful fix. The PR is ready at 311303b, and no code changes are needed. No conflicts. Only Body rules is not passing: two runs were cancelled, which fits the workflow concurrency after body edits, and the other 16 checks pass. Before merge, Body rules needs one completed pass at the head.

Not blocking, and fine to take or leave: the Android posture route (runEmulatorConsole(['posture', id]) in packages/platform-android/src/foldable/pose.ts) throws the adb timeout error on a late answer, so it has no typed possibly-applied reason, which could be a follow-up issue; the timed-out setPose test covers only the named pose, so a keyframe row in the same test.each would cover the other hint branch; the PR body says the old timed-out fold lacked the possibly-applied marker, but fold already carried it as a mutates-app command, so the gain is the reason, message and hint; the "costs about one read" comments could mention the 1 s kill grace past the 5 s deadline; and the scoped-set live run is attributed to 20f18fcd1, which is not an ancestor of the head, so a scoped-set smoke rerun at the head is optional.

Not verified here: any test run, since the tests-fail-on-base claims rest on reading the earlier code; the iPhone Duo live run output, screenshots and commit 20f18fcd1; the timeout branches of the dispatch and last panel read on a real simulator, which need fault injection; whether a keyframe retry replays from the first keyframe, because the Swift fold helper was not read; and whether a Body rules run has completed at the head.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 23, 2026
An emulator console that answers the posture command late may still apply it,
so the adb timeout no longer surfaces as a plain adb failure. fold now refuses
with fold-posture-dispatch-timed-out and dispatched: unknown, and the hint says
how to check the pose and that a retry sends the posture again. A failed adb
exit and a cancelled request keep their own errors.
A named pose and a keyframe trajectory now each get the retry hint that
applies to them: a named pose is sent again and read back, and keyframes replay
from the first one. The timeout test covers both.
@imranbarbhuiya

Copy link
Copy Markdown
Contributor Author
  • Done in 0e9a543: a timed-out adb emu posture now refuses with fold-posture-dispatch-timed-out and dispatched: unknown, with its own hint; a failed adb exit and a cancelled request keep their errors.
  • Done in cebd200: the timeout table has a keyframe row, and named poses and keyframes now each get their own retry hint.
  • Done in the PR body: it now says fold already carried dispatched: unknown, and the change is the reason, message and hint.
  • Done in 97e2bc2: both "about one read" comments mention the 1 s kill grace on a timed-out read.
  • Done: reran both device sets on the iPhone Duo simulator at 97e2bc2. All three poses reported the panel the screenshot showed, and a Settings tap after fold open worked in each set.

@thymikee thymikee removed the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 23, 2026
@thymikee

Copy link
Copy Markdown
Member

Thanks for the update.

The code at 97e2bc2 looks good, and the concerns from the earlier review (#5031 (comment)) are now fixed. All 15 checks pass at this commit, and nothing remains to change before merge.

Not verified here: the timeout branches (a late Android console answer, a helper set that outlives its deadline) were not run on a device, since they need fault injection. The non-timeout paths are unchanged in this delta, and the live runs in the PR exercise them. The Swift fold helper was not read, so the keyframe-retry hint relies on the payload carrying the whole keyframe array. A custom Android adb provider that returns a failed result instead of throwing on its own timeout would not carry details.timeoutMs, so it would take the plain exit-error path. That depends on the provider and is outside this PR. No tests were run locally.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 23, 2026
@thymikee
thymikee merged commit fae2676 into callstack:main Nov 23, 2026
15 checks passed
@imranbarbhuiya
imranbarbhuiya deleted the fix/fold-followups branch November 23, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants